	#include <iostream>
using namespace std;
bool ryear(int year)
{
	if((year%4==0&&year%100!=0)||year%400==0) return true;
	else return false;
}
int main()
{
	int year,month,day,sum=0;
	int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>year>>month>>day;
	for(int i=1;i<month;i++)
	{
		sum+=a[i];
		if(i==2&&ryear(year)) sum++;
	}
	cout<<sum+day;
	return 0;
}
